package main

import (
	"cybertwin/access/ap"
	"cybertwin/utils/configtools"
	"fmt"

	"github.com/panjf2000/gnet/v2"
	"github.com/panjf2000/gnet/v2/pkg/logging"
	log "github.com/sirupsen/logrus"
)

func main() {
	ss := &ap.AP{
		Network:   "tcp",
		Addr:      fmt.Sprintf(":%d", configtools.GlobalConfiguration.GetInt("ap.port")),
		Multicore: configtools.GlobalConfiguration.GetBool("ap.multicore"),
	}
	ss.LoadPrivateKey("./ca/ap", "privateKey.pem")
	log.Infoln("[ap-server]-[LoadPrivateKey]-成功从./ca/ap/privateKey.pem加载私钥")
	err := gnet.Run(ss, ss.Network+"://"+ss.Addr, gnet.WithMulticore(ss.Multicore))
	logging.Infof("server exits with error: %v", err)
}
